home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 49 / Amiga Format CD49 (2000-01-17)(Future Publishing)(GB)(Track 1 of 3)[!][issue 2000-02].iso / +system+ / tools / sound / ahi / developer / devloper.lzx / examples / Low-level / lib / AHI_lib.c next >
C/C++ Source or Header  |  1979-04-22  |  1KB  |  67 lines

  1. /*
  2.   These SAS/C autoopen/autoclose functions was supplied by Mattias
  3.   Karlsson. Thanks!
  4. */
  5.  
  6. #define USE_AHI_VERSION 4
  7.  
  8. #include <devices/ahi.h>
  9. #include <proto/ahi.h>
  10. #include <proto/exec.h>
  11. #include <dos.h>
  12.  
  13. extern void __regargs __autoopenfail(char *);
  14.  
  15. extern long __oslibversion;
  16.  
  17. struct Library    *AHIBase;
  18. struct MsgPort    *AHImp=NULL;
  19. struct AHIRequest *AHIio=NULL;
  20. BYTE               AHIDevice=-1;
  21.  
  22. // Autoopen rutin för ahi.
  23. int __stdargs _STI_openahi(void)
  24. {
  25.  
  26.     if(AHImp=CreateMsgPort())
  27.       {
  28.         if(AHIio=(struct AHIRequest *)CreateIORequest(AHImp,sizeof(struct AHIRequest)))
  29.         {
  30.             AHIio->ahir_Version=USE_AHI_VERSION;
  31.  
  32.             if(!(AHIDevice=OpenDevice(AHINAME,AHI_NO_UNIT,(struct IORequest *)AHIio,NULL)))
  33.             {
  34.                 AHIBase=(struct Library *)AHIio->ahir_Std.io_Device;
  35.                 return 0;
  36.             }
  37.         }
  38.     }
  39.  
  40.     // Så vi får rätt version angivelse
  41.     __oslibversion=USE_AHI_VERSION;
  42.     __autoopenfail("ahi.device");
  43.      return 1;
  44. }
  45.  
  46. // autoclose rutin finns det oxo :)
  47. void __stdargs _STD_closeahi(void)
  48. {
  49.  
  50.     if(AHIDevice==0)
  51.     {
  52.         CloseDevice((struct IORequest *)AHIio);
  53.     }
  54.  
  55.     if(AHIio)
  56.     {
  57.       DeleteIORequest((struct IORequest *)AHIio);
  58.       AHIio=NULL;
  59.     }
  60.  
  61.     if(AHImp)
  62.     {
  63.         DeleteMsgPort(AHImp);
  64.         AHImp=NULL;
  65.     }
  66. }
  67.